{include file="header.html"}
<script type="text/javascript" src="templates/js/jquery.colorbox.js" charset="utf-8"></script>
<link href="templates/style/colorbox.css" rel="stylesheet" type="text/css" />
<script src="templates/jsnew/MediaStreamRecorder.js"> </script>
<script type="text/javascript">
$(function(){
    $('#acategory_form').validate({
        errorPlacement: function(error, element){
            // $(element).next('.noerror').hide();
             //$(element).after(error);
        },
        success       : function(element){
        	 $(element).next('.noerror').show();  
        	 $(element).remove();
        	
        },
        rules : {    
        	hzshow : {
               required : true
            },
            g_owner_tel : {
                required : true
			},
			g_cartype : {
				required : true
			},
			g_consignor : {
				required : true
			},
			g_consignor_tel : {
				required : true
			},
			g_loading_date : {
				required : true
			},
			g_loading_place : {
				required : true
			},
			g_consignee : {
				required : true
			},
			g_consignee_tel : {
				required : true
			},
			g_unloading_date : {
				required : true
			},
			g_unloading_place : {
				required : true
			}
        },
        messages : {
        	hzshow : {
                required : '货主必填'
            },
            g_owner_tel : {
               required : '货主电话必填'
            },
			g_cartype : {
				required : '车型必选'
			},
			g_consignor : {
				required : '发货人必填'
			},
			g_consignor_tel : {
				required :  '发货人电话必填'
			},
			g_loading_date : {
				required :  '装货时间必填'
			},
			g_loading_place : {
				required : '装货地必填'
			},
			g_consignee : {
				required : '收货人必填'
			},
			g_consignee_tel : {
				required : '收货人电话必填'
			},
			g_unloading_date : {
				required : '卸货时间必填'
			},
			g_unloading_place : {
				required : '卸货地必填'
			}
        }
    });
    $("#zimg").click(function(){
  	  $w=$(window).width();
        $h=$(window).height();
        $w=$w*0.7;
        $("#opframe").attr("src","index.php?app=datarefer&act=chooseop&wid="+$("#wm_tid").val());
    	$("#opframe").width($w);
        $.colorbox({
            width : $w+20,
            height : "650px",
            inline : true,
            href : "#oplist"
        });
	});
    $('#g_tgdate').datetimepicker({changeMonth: true,changeYear: true});
	$('#g_rdate').datetimepicker({changeMonth: true,changeYear: true});
    $('#g_unloading_date').datetimepicker({changeMonth: true,changeYear: true});
    $('#g_loading_date').datetimepicker({changeMonth: true,changeYear: true});
    $("#Sub").click(function(){
	      $('#acategory_form').submit();
        
 	});

    $("#himg").live('click',function(){
		var id=$(this).attr("item");
		$w=$(window).width();
      $h=$(window).height();
      $w=$w*0.7;
      $("#hzframe").attr("src","index.php?app=datarefer&act=choosehz"+"&hzid="+id);
  	$("#hzframe").width($w);
      $.colorbox({
          width : $w+20,
          height : "650px",
          inline : true,
          href : "#hzlist"
      });
	});

    /*拆分货物弹出层*/
    $("#split").click(function(){
        $w=$(window).width();
        $h=$(window).height();
        $w=$w*0.7;
        $("#tagframe").attr("src","index.php?app=goods_normal&act=chooseop&gtid="+$(this).attr("item"));
        $("#tagframe").width($w);
        $.colorbox({
            width : $w+20,
            height : "650px",
            inline : true,
            href : "#taglist"
        });
    });
});
function changeop(id,name){
	$('opframe').colorbox.close();
	$("#operator").val(id);
	$("#operatorshow").val(name);
}
function changehz(id,name,hzid,linkman,linktel){
	$('hzframe').colorbox.close();
	if(hzid==''){

		$("[id='g_ownertid_']").val(id);
		$("#g_ownertid_"+hzid).val(id);
		$("#hzshow").val(name);
		$("#g_loading_man").val(linkman);
		$("#g_owner_tel").val(linktel);
	}else{

		$("[id='g_ownertid_"+hzid+"']").val(id);
		$("#g_ownertid_"+hzid).val(id);
		$("#hzshow"+hzid).val(name);
		$("#g_loading_man"+hzid).val(linkman);
		$("#g_owner_tel"+hzid).val(linktel);
	}
	$("#g_loading_man").val(linkman);
	$("#g_owner_tel").val(linktel);

}

function cargotimeimg (type,number,id){
	
	if(type==1){
		if(number==1){
			$('#g_tgdate'+id).focus();
		}else if(number==2){
			$('#g_loading_date'+id).focus();
		}else if (number==3){
			$('#g_unloading_date'+id).focus();
		}else if(number==4){
			$('#g_rdate'+id).focus();
		}
	}
}
var l=10000;

var mainid=0;
var mapsender=null;
var maptype;
	//地图选择
	function mapselect(mapid,id,sender,type){
		mainid=id;
		mapsender=sender;
		maptype=type;
		$w=$(window).width();
		$h=$(window).height();
		$w=$w*0.7;
        if(maptype==1){
			
        	$("#mapframe").attr("src","index.php?app=datarefer&act=mapselect&lng="+parseFloat($("[id='lng_']").val())+"&lat="+parseFloat($("[id='lat_']").val())+"&ret=window.parent.mapresult&address="+'{$auth.g_loading_place}');

		}
		else if (maptype==2){

			$("#mapframe").attr("src","index.php?app=datarefer&act=mapselect&lng="+parseFloat($("[id='un_lng_']").val())+"&lat="+parseFloat($("[id='un_lat_']").val())+"&ret=window.parent.mapresult&address="+'{$auth.g_unloading_place}');
		
		}

		$("#mapframe").width($w);
		$.colorbox({
			width : $w+20,
			height : "650px",
			inline : true,
			href : "#maplist"
		});
	}
	
	function mapresult(lng,lat,addr){
		$('mapframe').colorbox.close();
	
		if(maptype==1){
			$("#lng_").val(lng);
			$("#lat_").val(lat);
			$("#g_loading_place").val(addr);
		}
		else if (maptype==2){

			$("#un_lng_").val(lng);
			$("#un_lat_").val(lat);
			$("#g_unloading_place").val(addr);
			
		}
		if(mapsender!=null){
			$(mapsender).html()
		}
		if($("#lat_").val()>0&&$("#lng_").val()>0){
			$("#g_loading_placeimg").attr("src","templates/images/newadmin/map1.png");
		}
		
		if($("#un_lng_").val()>0&&$("#un_lat_").val()>0){
			$("#g_unloading_placeimg").attr("src","templates/images/newadmin/map1.png");
		}
		
	}

</script>
<style>
.infoTable {
	margin: 0 0 0 0;
}

.info th {
	text-align: right;
	padding-right: 15px;
}

#form11 th,#form1 th {
	text-align: right;
	padding-right: 15px;
}
</style>
<div style="display: none"  >
	<div id="maplist">
		<iframe id="mapframe" width="" height="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>

<div id="rightTop">
	<p class="info_menu">
		<a href="javascript:void(0);" class="index">控制台</a>&nbsp;>&nbsp;<a
			href="javascript:void(0);">整车货单</a>&nbsp;>&nbsp;<span>货单编号
			{$auth.g_code}</span>
	</p>
	<ul class="subnav">
		<li><a class="btn1" href="index.php?app=goods_normal">{$lang.manage}</a>
		</li>
		<!-- {if $auth.g_tid}} -->
		<li><a class="btn1" href="index.php?app=goods_normal&amp;act=add">{$lang.add}</a>
		</li>
		<li><span>编辑</span>
		</li>
		<!-- {else} -->
		<li><span>新建</span></li>
		<!-- {/if} -->
	</ul>
</div>

<div style="display: none">
	<div id="hzlist">
		<iframe id="hzframe" width="" height="600px" frameborder="0"
			scrolling="no"></iframe>
	</div>
</div>

<div style="display: none"  >
	<div id="oplist">
	<iframe id="opframe" width="" height="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>


<div class="info">
	<div class="infoTable" style="padding-left: 10px;padding-top: 20px">
		<!--选中承运商-->
		{if $auth.g_tid}
		<input class="formbtn" type="button" id="split" item = "{$auth.g_tid}" value="提交货物">
		{/if}
	</div>
	<form method="post" enctype="multipart/form-data" id="acategory_form">
		<div class="jui-cut-label fn-mt25">
			<div class="jui-message-bar">基本信息</div>
		</div>
		<input type="hidden" name="wm_code" value="{$auth.wm_code}"
			class="mls_names">

		<table class="infoTable">

			<tr>
				<th>单号:</th>
				<td style="text-align: left;">{$auth.g_code} <input
					class='infoTableInput' id="g_code" type='hidden' name='g_code'
					value='{$auth.g_code}' /></td>

				<th class="paddingT15">类型:</th>
				<td style="text-align: left;"><input class='infoTableInput'
					id="g_type" type='hidden' name='g_type' value='' /> <span
					id="g_type2">{$auth.g_type|default:整车}</span></td>

				<th class="paddingT15">下单时间:</th>
				<td style="text-align: left;">{$auth.g_opdate|date:Y-m-d H:i:s}
				</td>
				<th class="paddingT15">下单人:</th>
				<td style="text-align: left;">
					<!-- {if !$auth.user_name}} --> {$g_opname} <!-- {else}} -->
					{$auth.user_name} <!-- {/if} --></td>
				<th></th>
				<td></td>
			</tr>
		</table>
		<HR style="FILTER: alpha(opacity = 100, finishopacity = 0, style = 1)"
			size="1" width="83%" color="#ccc">

		<table class="infoTable">
			<tr>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>货主:</th>
				<td>
					<input type="hidden" value="{$auth.g_ownertid}" name="g_ownertid" id="g_ownertid_{$s.g_tid}">
					<input type="text"  placeholder="货主必填" value="{$auth.o_name}" item="{$s.g_tid}" name="hzshow" id="hzshow" class="infoTableInput"
					urldata="index.php?app=datarefer&act=gethz" urlval="index.php?app=datarefer&act=gethzinfo" >
					<a href="javascript:void(0);" class="right_a" item="{$s.g_tid}" id="himg"><img src="templates/images/newadmin/serch.png" alt=""></a>
					<script>
						refer("hzshow","g_ownertid_{$s.g_tid}");
					</script>
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>货主电话:</th>
				<td class="paddingT15 wordSpacing5">
					<input 	class="infoTableInput" id="g_owner_tel" placeholder="必填" type="text" name="g_owner_tel" value="{$auth.g_owner_tel}" />
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>车型:</th>
				<td class="paddingT15 wordSpacing5">
					<select   class="infoTableInput"  name="g_cartype" id="g_cartype">
						{html_options options=$g_cartypes selected=$auth.g_cartype}
					</select>
				</td>
			</tr>
			<tr>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>发货人:</th>
				<td class="paddingT15 wordSpacing5"><input type="text"
														   name="g_consignor" value="{$auth.g_consignor}"
														   class="infoTableInput" id="g_consignor">
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>发货人电话:</th>
				<td class="paddingT15 wordSpacing5"><input type="text"
														   name="g_consignor_tel" value="{$auth.g_consignor_tel}"
														   class="infoTableInput" id="g_consignor_tel">
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>装货时间:</th>
				<!-- {if $auth.g_loading_date}} -->
				<td class="paddingT15 wordSpacing5">
					<input type="text" name="g_loading_date" value="{$auth.g_loading_date|date:Y-m-d H:i}" class="infoTableInput" id="g_loading_date">
					<a href="javascript:void(0);" onclick="cargotimeimg('1','2','');" class="right_a"><img src="templates/images/newadmin/rili.png" alt=""></a>
				</td>
				<!-- {else}} -->
				<td class="paddingT15 wordSpacing5">
					<input type="text" name="g_loading_date" value="-" class="infoTableInput" id="g_loading_date">
					<a href="javascript:void(0);" onclick="cargotimeimg('1','2','');" class="right_a"><img src="templates/images/newadmin/rili.png" alt=""></a>
				</td>
				<!-- {/if} -->
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>装货地:</th>
				<td class="paddingT15 wordSpacing5"><input
						class="infoTableInput" id="g_loading_place" type="text"
						name="g_loading_place" value="{$auth.g_loading_place}" urldata="index.php?app=datarefer&act=getaddr" urlval="index.php?app=datarefer&act=getaddrinfo"/> <a
						href="javascript:void(0);"
						onclick="mapselect('#haul_{$auth.g_tid}_h_address','{$auth.g_tid}',this,1);"
						class="right_a" >
					{if $auth.g_loading_lng>0&&$auth.g_loading_lat}<img id='g_loading_placeimg' src="templates/images/newadmin/map1.png" alt="" id="mapimg_{$h.h_tid}">{else}<img id='g_loading_placeimg' src="templates/images/newadmin/map.png" alt="" id="mapimg_{$h.h_tid}">{/if}</a>

					<input type="hidden" name="g_loading_lng"
						   value="{$auth.g_loading_lng}"
						   class="infoTableInput" id="lng_">


					<input type="hidden" name="g_loading_lat"
						   value="{$auth.g_loading_lat}"
						   class="infoTableInput" id="lat_">
					<script>
						addrrefer("g_loading_place","lng_","lat_","g_loading_placeimg");
					</script>
				</td>
			</tr>
			<tr>
				<th class="paddingT15" id="place1"><b style="color: #ff0000">*&nbsp;</b>收货人:</th>
				<td class="paddingT15 wordSpacing5">
					<input type="text" name="g_consignee" value="{$auth.g_consignee}" class="infoTableInput" id="g_consignee">
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>收货人电话:</th>
				<td class="paddingT15 wordSpacing5">
					<input type="text" name="g_consignee_tel" value="{$auth.g_consignee_tel}" class="infoTableInput" id="g_consignee_tel">
				</td>
				<th class="paddingT15"><b style="color: #ff0000">*&nbsp;</b>卸货时间:</th>
				<!-- {if $auth.g_unloading_date}} -->
				<td class="paddingT15 wordSpacing5">
					<input type="text" name="g_unloading_date" value="{$auth.g_unloading_date|date:Y-m-d H:i}" class="infoTableInput" id="g_unloading_date">
					<a href="javascript:void(0);" onclick="cargotimeimg('1','3','');" class="right_a"><img src="templates/images/newadmin/rili.png" alt=""></a>
				</td>
				<!-- {else}} -->
				<td class="paddingT15 wordSpacing5">
					<input type="text" name="g_unloading_date" value="-" class="infoTableInput" id="g_unloading_date">
					<a href="javascript:void(0);" onclick="cargotimeimg('1','3','');" class="right_a"><img src="templates/images/newadmin/rili.png" alt=""></a>
				</td>
				<!-- {/if} -->
				<th class="paddingT15" id="time2"><b style="color: #ff0000">*&nbsp;</b>卸货地:</th>
				<td class="paddingT15 wordSpacing5"><input
					class="infoTableInput" id="g_unloading_place" type="text"
					name="g_unloading_place" value="{$auth.g_unloading_place}" urldata="index.php?app=datarefer&act=getaddr" urlval="index.php?app=datarefer&act=getaddrinfo"/> <a
					href="javascript:void(0);"
					onclick="mapselect('#haul_{$auth.g_tid}_h_address','{$auth.g_tid}',this,2);"
					class="right_a"> {if $auth.g_unloading_lng>0&&$auth.g_unloading_lat}<img id='g_unloading_placeimg' src="templates/images/newadmin/map1.png" alt="" id="mapimg_{$h.h_tid}">{else}<img src="templates/images/newadmin/map.png" id='g_unloading_placeimg' alt="" id="mapimg_{$h.h_tid}">{/if}</a>
					<input type="hidden" name="g_unloading_lng"
						   value="{$auth.g_unloading_lng}" class="infoTableInput"
						   id="un_lng_">

					<input type="hidden" name="g_unloading_lat"
						   value="{$auth.g_unloading_lat}" class="infoTableInput"
						   id="un_lat_">
					<script>
						addrrefer("g_unloading_place","un_lng_","un_lat_","g_unloading_placeimg");
					</script>
				</td>
			</tr>
			<tr>
				<th class="paddingT15">备注:</th>
				<td class="paddingT15 wordSpacing5" colspan="5"><textarea
						name="g_note" id="g_note" rows="3" style="width: 100%">{$auth.g_note}</textarea>
					<label></label></td>
			</tr>
			<tr>
				<th></th>
				<td class="ptb20" style="text-align: left;">
					{if $isbool==1}
					<input class="formbtn" type="button" id="Sub" name="Submit" value="{$lang.submit}" />
					{/if}
				</td>
			</tr>
	</table>
	</form>
</div>

<!--拆单弹出层-->
<div style="display: none">
	<div id="taglist">
		<iframe id="tagframe"
			src="index.php?app=goods_normal&act=chooseop" width=""
			height="600px" frameborder="0" scrolling="no"></iframe>
	</div>
</div>

{include file="footer.html"}
